#ifndef __WxvtkFreeTypeUtilitiesUnicode_h
#define __WxvtkFreeTypeUtilitiesUnicode_h

#include <vtkObject.h>
#include "WxvtkTextPropertyUnicode.h"
#include "WxExtentionExports.h"

#define VTK_FTFC_CACHE_CAPACITY 150

class vtkImageData;
class WxvtkTextPropertyUnicode;

// FreeType

#include "vtk_freetype.h"  //since ft2build.h could be in the path
#include FT_FREETYPE_H
#include FT_GLYPH_H

#if (FREETYPE_MAJOR >2 ||(FREETYPE_MAJOR == 2 && ( FREETYPE_MINOR > 1 || (FREETYPE_MINOR == 1 && FREETYPE_PATCH >= 9))))
# include FT_CACHE_H
// This flag will be used to check if Caching support is to be compiled.
# define VTK_FREETYPE_CACHING_SUPPORTED
#endif

class FTFont;

//----------------------------------------------------------------------------
// Singleton cleanup

class WxExtention_EXPORT WxvtkFreeTypeUtilitiesUnicodeCleanup
{
public:
        WxvtkFreeTypeUtilitiesUnicodeCleanup();
        ~WxvtkFreeTypeUtilitiesUnicodeCleanup();
};

//----------------------------------------------------------------------------
// Singleton font cache

class WxExtention_EXPORT  WxvtkFreeTypeUtilitiesUnicode : public vtkObject
{
public:
        vtkTypeRevisionMacro(WxvtkFreeTypeUtilitiesUnicode, vtkObject);
	void PrintSelf(ostream& os, vtkIndent indent);

	// Description:
	// This is a singleton pattern New. There will be only ONE reference 
        // to a WxvtkFreeTypeUtilitiesUnicode object per process.  Clients that
	// call this method must use Delete() on the object so that reference
	// counting will work. The single instance will be unreferenced when
	// the program exits. You should just use the static GetInstance() method
	// anyway to get the singleton.
        static WxvtkFreeTypeUtilitiesUnicode *New();

	// Description:
	// Return the singleton instance with no reference counting.
        static WxvtkFreeTypeUtilitiesUnicode* GetInstance();

	// Description:
	// Supply a user defined instance. Call Delete() on the supplied
	// instance after setting it to fix the reference count.
        static void SetInstance(WxvtkFreeTypeUtilitiesUnicode *instance);

	// Old Code
	// Cache entry
	
	struct Entry
	{
                WxvtkTextPropertyUnicode *TextProperty;
		FTFont *Font;
		float LargestAscender;
		float LargestDescender;
	};

        WxvtkFreeTypeUtilitiesUnicode::Entry* GetFont(WxvtkTextPropertyUnicode *tprop,
		double override_color[3] = NULL);

protected:
        WxvtkFreeTypeUtilitiesUnicode();
        virtual ~WxvtkFreeTypeUtilitiesUnicode();

private:
        WxvtkFreeTypeUtilitiesUnicode(const WxvtkFreeTypeUtilitiesUnicode&);  // Not implemented.
        void operator=(const WxvtkFreeTypeUtilitiesUnicode&);  // Not implemented.

	// The singleton instance and the singleton cleanup instance

        static WxvtkFreeTypeUtilitiesUnicode* Instance;
        static WxvtkFreeTypeUtilitiesUnicodeCleanup Cleanup;

	// Old Code

	void PrintEntry(int i, char *msg = 0);
	void ReleaseEntry(int i);

	void InitializeCache();
	void ReleaseCache();

	Entry *Entries[VTK_FTFC_CACHE_CAPACITY];
	int NumberOfEntries;
};

#endif
